package com.demo.po;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;

/**
 * Blog model.

将表结构放在此，消除记忆负担
mysql> desc blog;
+---------+--------------+------+-----+---------+----------------+
  `id` int(11) NOT NULL auto_increment,
  `userid` varchar(200) NOT NULL,
  `name` varchar(200) NOT NULL,地址的name
  `posL` varchar(200) ,
  `posR` varchar(200) ,
  `addtype` varchar(200) ,
+---------+--------------+------+-----+---------+----------------+

数据库字段名建议使用驼峰命名规则，便于与 java 代码保持一致，如字段名： userId
 */
@SuppressWarnings("serial")
public class Address extends Model<Address> {
	public static final Address dao = new Address();
	
	/**
	 * 所有 sql 写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
	 */
	public Page<Address> paginate(int pageNumber, int pageSize) {
		return paginate(pageNumber, pageSize, "select *", "from blog order by id asc");
	}
	
	public void deleteById(String userid){
		Db.batch("delete from address where userid=?", new Object[][]{{userid}},100);
	}
	
}
